package com.ruoyi.system.domain;

import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 健康登记对象 health_register
 * 
 * @author ruoyi
 * @date 2021-05-10
 */
public class HealthRegister extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    /** $column.columnComment */
    private Long id;

    /** 用户id */
    @Excel(name = "用户id")
    private Long userId;

    /** 家人id */
    @Excel(name = "家人id")
    private Long familyId;

    /** 姓名 */
    @Excel(name = "姓名")
    private String name;

    @Excel(name = "性别")
    private Integer sex;

    /** 出生日期 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "出生日期", width = 30, dateFormat = "yyyy-MM-dd")
    private Date birthday;

    /** 身份证号 */
    @Excel(name = "身份证号")
    private String idCard;

    /** 工作单位 */
    @Excel(name = "工作单位")
    private String workPlace;

    /** 本人电话 */
    @Excel(name = "本人电话")
    private String phone;

    /** 联系人姓名 */
    @Excel(name = "联系人姓名")
    private String contactsName;

    /** 联系人电话 */
    @Excel(name = "联系人电话")
    private String contactsPhone;

    /** 常驻类型 */
    @Excel(name = "常驻类型")
    private Integer residence;

    /** 血型 */
    @Excel(name = "血型")
    private String blood;

    /** 文化程度 */
    @Excel(name = "文化程度")
    private Integer culture;

    /** 职业 */
    @Excel(name = "职业")
    private Integer occupation;

    /** 婚姻状况 */
    @Excel(name = "婚姻状况")
    private Integer marry;

    /** 医疗费用 */
    @Excel(name = "医疗费用")
    private String insurance;

    /** 民族 */
    @Excel(name = "民族")
    private String nationJson;

    /** 扩展 */
    @Excel(name = "扩展")
    private String extraJson;

    private Integer flag;

    private Date submitTime;

    private String remark;

    public void setId(Long id) 
    {
        this.id = id;
    }

    public Long getId() 
    {
        return id;
    }
    public void setUserId(Long userId) 
    {
        this.userId = userId;
    }

    public Long getUserId() 
    {
        return userId;
    }
    public void setFamilyId(Long familyId) 
    {
        this.familyId = familyId;
    }

    public Long getFamilyId() 
    {
        return familyId;
    }
    public void setName(String name) 
    {
        this.name = name;
    }

    public String getName() 
    {
        return name;
    }
    public void setBirthday(Date birthday) 
    {
        this.birthday = birthday;
    }

    public Date getBirthday() 
    {
        return birthday;
    }
    public void setIdCard(String idCard) 
    {
        this.idCard = idCard;
    }

    public String getIdCard() 
    {
        return idCard;
    }
    public void setWorkPlace(String workPlace) 
    {
        this.workPlace = workPlace;
    }

    public String getWorkPlace() 
    {
        return workPlace;
    }
    public void setPhone(String phone) 
    {
        this.phone = phone;
    }

    public String getPhone() 
    {
        return phone;
    }
    public void setContactsName(String contactsName) 
    {
        this.contactsName = contactsName;
    }

    public String getContactsName() 
    {
        return contactsName;
    }
    public void setContactsPhone(String contactsPhone) 
    {
        this.contactsPhone = contactsPhone;
    }

    public String getContactsPhone() 
    {
        return contactsPhone;
    }
    public void setResidence(Integer residence) 
    {
        this.residence = residence;
    }

    public Integer getResidence() 
    {
        return residence;
    }
    public void setBlood(String blood)
    {
        this.blood = blood;
    }

    public String getBlood()
    {
        return blood;
    }
    public void setCulture(Integer culture) 
    {
        this.culture = culture;
    }

    public Integer getCulture() 
    {
        return culture;
    }
    public void setOccupation(Integer occupation) 
    {
        this.occupation = occupation;
    }

    public Integer getOccupation() 
    {
        return occupation;
    }

    public void setMarry(Integer marry) 
    {
        this.marry = marry;
    }

    public Integer getMarry() 
    {
        return marry;
    }

    public void setNationJson(String nationJson) 
    {
        this.nationJson = nationJson;
        if(StringUtils.isNotBlank(nationJson)){
            Map<Integer, String> nationMap = JSONObject.parseObject(nationJson, Map.class);
            nationMap.keySet().stream().forEach(key ->{
                nationKey = key;
                nationText = nationMap.get(key);
            });
        }
    }

    public String getNationJson() 
    {
        return nationJson;
    }
    public void setExtraJson(String extraJson) 
    {
        this.extraJson = extraJson;
        if(StringUtils.isNotBlank(extraJson)){
            Map<String, String> extraMap = JSONObject.parseObject(extraJson, Map.class);
            String disease = extraMap.get("disease");
            if(StringUtils.isNotBlank(disease)){
                diseaseList = JSONObject.parseObject(disease, List.class);
            }
            String operation = extraMap.get("operation");
            if(StringUtils.isNotBlank(operation)){
                this.operation = JSONObject.parseObject(operation, Operation.class);
            }
            String allergy = extraMap.get("allergy");
            if(StringUtils.isNotBlank(allergy)){
                allergyList = JSONObject.parseObject(allergy, List.class);
            }

            String allergyOther = extraMap.get("allergyOther");
            if(StringUtils.isNotBlank(allergyOther)){
                this.allergyOther = allergyOther;
            }

            String trauma = extraMap.get("trauma");
            if(StringUtils.isNotBlank("trauma")){
                this.trauma = JSONObject.parseObject(trauma, Trauma.class);
            }

            String metachysis = extraMap.get("metachysis");
            if(StringUtils.isNotBlank("metachysis")){
                this.metachysis = JSONObject.parseObject(metachysis, Metachysis.class);
            }

            String heritable = extraMap.get("heritable");
            if(StringUtils.isNotBlank(heritable)){
                this.heritable = JSONObject.parseObject(heritable, Heritable.class);
            }

            String disability = extraMap.get("disability");
            if(StringUtils.isNotBlank(disability)){
                this.disabilityList = JSONObject.parseObject(disability, List.class);
            }

            String disabilityOther = extraMap.get("disabilityOther");
            if(StringUtils.isNotBlank(disabilityOther)){
                this.disabilityOther = disabilityOther;
            }

        }
    }

    public String getExtraJson() 
    {
        return extraJson;
    }

    public Integer getSex() {
        return sex;
    }

    public void setSex(Integer sex) {
        this.sex = sex;
    }

    private List<Integer> insuranceList;

    //民族key
    private Integer nationKey;
    //民族value
    private String nationText;

    //药物过敏史
    private List<Integer> allergyList;

    //其他药物过敏
    private String allergyOther;

    //疾病史
    private List<Integer> diseaseList;

    //输血史
    private Metachysis metachysis;

    //手术史
    private Operation operation;

    //外伤史
    private Trauma trauma;

    //遗传病史
    private Heritable heritable;

    //残疾情况
    private List<Integer> disabilityList;
    //其他残疾
    private String disabilityOther;

    //是否能审核
    private Boolean canExamine = false;

    public Operation getOperation() {
        return operation;
    }

    public void setOperation(Operation operation) {
        this.operation = operation;
    }

    public Integer getNationKey() {
        return nationKey;
    }

    public void setNationKey(Integer nationKey) {
        this.nationKey = nationKey;
    }

    public String getNationText() {
        return nationText;
    }

    public void setNationText(String nationText) {
        this.nationText = nationText;
    }

    public List<Integer> getDiseaseList() {
        return diseaseList;
    }

    public void setDiseaseList(List<Integer> diseaseList) {
        this.diseaseList = diseaseList;
    }

    public List<Integer> getAllergyList() {
        return allergyList;
    }

    public void setAllergyList(List<Integer> allergyList) {
        this.allergyList = allergyList;
    }

    public Trauma getTrauma() {
        return trauma;
    }

    public void setTrauma(Trauma trauma) {
        this.trauma = trauma;
    }

    public Metachysis getMetachysis() {
        return metachysis;
    }

    public void setMetachysis(Metachysis metachysis) {
        this.metachysis = metachysis;
    }

    public String getAllergyOther() {
        return allergyOther;
    }

    public void setAllergyOther(String allergyOther) {
        this.allergyOther = allergyOther;
    }

    public Heritable getHeritable() {
        return heritable;
    }

    public void setHeritable(Heritable heritable) {
        this.heritable = heritable;
    }

    public List<Integer> getDisabilityList() {
        return disabilityList;
    }

    public void setDisabilityList(List<Integer> disabilityList) {
        this.disabilityList = disabilityList;
    }

    public String getDisabilityOther() {
        return disabilityOther;
    }

    public void setDisabilityOther(String disabilityOther) {
        this.disabilityOther = disabilityOther;
    }

    public void setInsurance(String insurance) {
        this.insurance = insurance;
        if(StringUtils.isNotBlank(insurance)){
            this.insuranceList = JSONObject.parseObject(insurance, List.class);
        }
    }

    public List<Integer> getInsuranceList() {
        return insuranceList;
    }

    public void setInsuranceList(List<Integer> insuranceList) {
        this.insuranceList = insuranceList;
        if(CollectionUtils.isNotEmpty(insuranceList)){
            this.insurance = JSONObject.toJSONString(insuranceList);
        }
    }

    public String getInsurance() {
        return insurance;
    }

    public Integer getFlag() {
        return flag;
    }

    public void setFlag(Integer flag) {
        this.flag = flag;
    }

    public Date getSubmitTime() {
        return submitTime;
    }

    public void setSubmitTime(Date submitTime) {
        this.submitTime = submitTime;
    }

    @Override
    public String getRemark() {
        return remark;
    }

    @Override
    public void setRemark(String remark) {
        this.remark = remark;
    }

    public Boolean getCanExamine() {
        return canExamine;
    }

    public void setCanExamine(Boolean canExamine) {
        this.canExamine = canExamine;
    }
}
